<html>
<head><meta charset="utf-8"><title>Layout stability? · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html">Layout stability?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="168789630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168789630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168789630">(Jun 23 2019 at 11:02)</a>:</h4>
<p>AFAIK we don't say anything about layout stability yet in our "book"? I can't even find a section on the topic where we say that pretty much everything is open. And maybe we can at least say that running the same binary multiple times will always use the same layout?<br>
Also see <a href="https://internals.rust-lang.org/t/when-is-the-abi-stable/10420" target="_blank" title="https://internals.rust-lang.org/t/when-is-the-abi-stable/10420">https://internals.rust-lang.org/t/when-is-the-abi-stable/10420</a></p>



<a name="168789773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168789773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168789773">(Jun 23 2019 at 11:07)</a>:</h4>
<p>For structs we have (<a href="https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html#default-layout-repr-rust" target="_blank" title="https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html#default-layout-repr-rust">https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html#default-layout-repr-rust</a>):</p>
<blockquote>
<p>A note on determinism. The definition above does not guarantee determinism between executions of the compiler -- two executions may select different layouts, even if all inputs are identical. Naturally, in practice, the compiler aims to produce deterministic output for a given set of inputs. However, it is difficult to produce a comprehensive summary of the various factors that may affect the layout of structs, and so for the time being we have opted for a conservative definition.</p>
</blockquote>



<a name="168789834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168789834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168789834">(Jun 23 2019 at 11:09)</a>:</h4>
<p>hm I see. that doesn't really have anything to do with structs though?  It should be in a dedicated section IMO.</p>



<a name="168792041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168792041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168792041">(Jun 23 2019 at 12:15)</a>:</h4>
<p>issue created at <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/151" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/151">https://github.com/rust-lang/unsafe-code-guidelines/issues/151</a></p>



<a name="168797204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168797204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168797204">(Jun 23 2019 at 15:09)</a>:</h4>
<p>A lot of this exists in nascent form at <a href="https://doc.rust-lang.org/stable/reference/type-layout.html" target="_blank" title="https://doc.rust-lang.org/stable/reference/type-layout.html">https://doc.rust-lang.org/stable/reference/type-layout.html</a></p>



<a name="168846559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout%20stability%3F/near/168846559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Layout.20stability.3F.html#168846559">(Jun 24 2019 at 12:55)</a>:</h4>
<p>What do you have in mind ?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>